<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="姓名" prop="spName">
        <el-input
            v-model="queryParams.spName"
            placeholder="请输入姓名"
            clearable
            @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="手机号" prop="contactPhone">
        <el-input
            v-model="queryParams.contactPhone"
            placeholder="请输入手机号"
            clearable
            @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="城市" prop="cityCode">
        <el-cascader-area v-model="queryParams.cityCode" :qrtType="1"></el-cascader-area>
      </el-form-item>
      <el-form-item label="教练类型" prop="serviceType">
        <el-select v-model="queryParams.serviceType" placeholder="请选择教练类型" clearable>
          <el-option
              v-for="dict in t_sp_service_type"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择状态" clearable>
          <el-option
              v-for="dict in t_sp_status"
              :key="dict.value"
              :label="dict.label"
              :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="经销商" prop="parName">
        <el-input
            v-model="queryParams.parName"
            placeholder="请输入经销商"
            clearable
            @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否启用" prop="isPublish">
        <el-select v-model="queryParams.isPublish" placeholder="请选择是否启用" clearable>
          <el-option
              v-for="dict in t_is_yes"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
            type="primary"
            plain
            icon="Plus"
            @click="handleAdd"
            v-hasPermi="['system:tsp:add']"
        >新增
        </el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
            type="warning"
            plain
            icon="Download"
            @click="handleExport"
            v-hasPermi="['system:tsp:export']"
        >导出
        </el-button>
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="spList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="昵称/姓名" align="center" prop="spName">
        <template #default="scope">
          {{ scope.row.nickName }}/{{ scope.row.spName }}
        </template>
      </el-table-column>
      <el-table-column label="头像" align="center" prop="spAvatar">
        <template #default="scope">
          <image-preview :src="scope.row.userAvatar" :width="50" :height="50" v-if="scope.row.spId === null"/>
          <image-preview :src="scope.row.spAvatar" :width="50" :height="50" v-if="scope.row.spId != null"/>
        </template>
      </el-table-column>
      <el-table-column label="教练类型" align="center" prop="serviceType">
        <template #default="scope">
          <dict-tag :options="t_sp_service_type" :value="scope.row.serviceType"/>
        </template>
      </el-table-column>
      <el-table-column label="手机号" align="center" prop="contactPhone">
        <template #default="scope">
          <p v-if="scope.row.spId != null">{{ scope.row.contactPhone }}</p>
          <p v-else>{{ scope.row.userPhone }}</p>
        </template>
      </el-table-column>
      <el-table-column label="城市" align="center" prop="cityName"/>
      <el-table-column label="状态" align="center" prop="status">
        <template #default="scope">
          <dict-tag :options="t_sp_status" :value="scope.row.status"/>
        </template>
      </el-table-column>
      <el-table-column label="性别" align="center" prop="sex">
        <template #default="scope">
          <dict-tag :options="sys_user_sex" :value="scope.row.sex"/>
        </template>
      </el-table-column>
      <el-table-column label="出生日期" align="center" prop="birthDate" width="180">
        <template #default="scope">
          <span>{{ parseTime(scope.row.birthDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="从业年限" align="center" prop="workYears"/>
      <el-table-column label="服务时长" align="center" prop="serviceTime">
        <template #default="scope">
          <dict-tag :options="t_sp_service_time" :value="scope.row.serviceTime"/>
        </template>
      </el-table-column>
      <el-table-column label="1v1价格" align="center" prop="price"/>
      <el-table-column label="1v2价格" align="center" prop="price2"/>
      <el-table-column label="经销商" align="center" prop="parName"/>
      <el-table-column label="钱包余额" align="center" prop="balance"/>
      <el-table-column label="评分" align="center" prop="evalScore"/>
      <el-table-column label="平台推荐" align="center" prop="platRec">
        <template #default="scope">
          <dict-tag :options="t_is_yes" :value="scope.row.platRec"/>
        </template>
      </el-table-column>
      <el-table-column label="是否启用" align="center" prop="isPublish">
        <template #default="scope">
          <dict-tag :options="t_is_yes" :value="scope.row.isPublish"/>
        </template>
      </el-table-column>
      <el-table-column label="审核原因" align="center" prop="statusReason"/>
      <el-table-column label="操作" align="center" width="150" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button link type="primary" icon="View" @click="handleView(scope.row)"
                     v-if="scope.row.spId != null"
                     v-hasPermi="['system:tsp:query']">查看
          </el-button>
          <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)"
                     v-if="scope.row.spId != null"
                     v-hasPermi="['system:tsp:edit']">
            修改
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
        v-show="total>0"
        :total="total"
        v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize"
        @pagination="getList"
    />

    <!-- 添加或修改教练对话框 -->
    <el-dialog :title="title" v-model="open" width="1000px" append-to-body>
      <el-form ref="spRef" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="头像" prop="spAvatar">
              <image-upload v-model="form.spAvatar" :limit="1"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="教练类别" prop="serviceType">
              <el-select v-model="form.serviceType" placeholder="请选择教练类别" @change="handleServiceTypeChange">
                <el-option
                    v-for="dict in t_sp_service_type"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="经销商" prop="parId">
              <par-select :key="refreshTime" v-model="form.parId"></par-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="姓名" prop="spName">
              <el-input v-model="form.spName" placeholder="请输入姓名" maxlength="20"/>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="!(form.userId > 0)">
            <el-form-item label="手机号" prop="contactPhone">
              <el-input v-model="form.contactPhone" placeholder="请输入手机号"/>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="form.userId > 0">
            <el-form-item label="手机号" prop="contactPhone">
              {{ form.contactPhone }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="从业年限" prop="workYears">
              <el-input-number v-model="form.workYears" :max="99" :min="0" value-on-clear="1" :precision="0"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="出生日期" prop="birthDate">
              <el-date-picker clearable
                              v-model="form.birthDate"
                              type="date"
                              value-format="YYYY-MM-DD"
                              placeholder="请选择出生日期"
              ></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="个人标签" prop="tagList">
              <el-select v-model="form.tagList" multiple :multiple-limit="5" placeholder="请选择个人标签">
                <el-option
                    v-for="dict in t_sp_tag"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="性别" prop="sex">
              <el-select v-model="form.sex" placeholder="请选择性别">
                <el-option
                    v-for="dict in sys_user_sex"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="服务时长" prop="serviceTime">
              <el-select v-model="form.serviceTime" placeholder="请选择服务时长">
                <el-option
                    v-for="dict in t_sp_service_time"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="个人简介" prop="spDesc">
              <el-input v-model="form.spDesc" type="textarea" placeholder="请输入内容" maxlength="1000"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="form.serviceType === '1'">
          <el-col :span="12">
            <el-form-item label="1v1价格" prop="price">
              <el-select v-model="form.price" placeholder="请选择1v1价格" @change="handleChange">
                <el-option
                    v-for="dict in t_sp_price_1"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="1v2价格" prop="price2" v-if="form.serviceType === '1'">
              {{ form.price2 }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row v-if="form.serviceType === '2'">
          <el-col :span="12">
            <el-form-item label="1v1价格" prop="price">
              <el-select v-model="form.price" placeholder="请选择1v1价格">
                <el-option
                    v-for="dict in t_sp_price_2"
                    :key="dict.value"
                    :label="dict.label"
                    :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="地区" prop="areaCode">
              <el-cascader-area v-model="form.areaCode" :qrtType="2"></el-cascader-area>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="详细地址" prop="addr">
              <el-input v-model="form.addr" type="textarea" placeholder="请输入详细地址"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <map-component :key="mapComponentKey"
                           :longitude="form.longitude" :latitude="form.latitude"
                           @coordinateClicked="handleCoordinateClicked"
            ></map-component>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="个人风采" prop="showPic">
              <image-upload v-model="form.showPic" :limit="9"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="资质证明" prop="certPic">
              <image-upload v-model="form.certPic" :limit="9"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="平台推荐" prop="platRec">
              <el-select v-model="form.platRec" placeholder="请选择平台推荐" clearable>
                <el-option
                    v-for="dict in t_is_yes"
                    :key="dict.value"
                    :label="dict.label"
                    :value="parseInt(dict.value)"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否启用" prop="isPublish">
              <el-select v-model="form.isPublish" placeholder="请选择是否启用" clearable>
                <el-option
                    v-for="dict in t_is_yes"
                    :key="dict.value"
                    :label="dict.label"
                    :value="parseInt(dict.value)"
                />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>

    <el-dialog title="教练详情" v-model="viewOpen" width="1000px" append-to-body>
      <el-form ref="spRefView" :model="form" label-width="80px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="头像" prop="spAvatar">
              <image-preview :src="form.spAvatar" :width="150" :height="150"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="教练类型" prop="serviceType">
              <dict-tag :options="t_sp_service_type" :value="form.serviceType"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="经销商" prop="parName">
              {{ form.parName }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="姓名" prop="spName">
              {{ form.spName }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="手机号" prop="contactPhone">
              {{ form.contactPhone }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="从业年限" prop="workYears">
              {{ form.workYears }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="出生日期" prop="birthDate">
              {{ parseTime(form.birthDate, '{y}-{m}-{d}') }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="个人标签" prop="tagList">
              <dict-tag :options="t_sp_tag" :value="form.tagList" :showValue="false"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="性别" prop="sex">
              <dict-tag :options="sys_user_sex" :value="form.sex"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="服务时长" prop="serviceTime">
              <dict-tag :options="t_sp_service_time" :value="form.serviceTime"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="个人简介" prop="spDesc">
              {{ form.spDesc }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="1v1价格" prop="price">
              {{ form.price }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="1v2价格" prop="price2" v-if="form.serviceType === '1'">
              {{ form.price2 }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="详细地址" prop="addr">
              {{ form.addrDesc }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="个人风采" prop="showPicList">
              <image-preview :src-list="form.showPicList" :width="150" :height="150"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="资质证明" prop="certPicList">
              <image-preview :src-list="form.certPicList" :width="150" :height="150"/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="平台推荐" prop="platRec">
              <dict-tag :options="t_is_yes" :value="form.platRec"/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否启用" prop="isPublish">
              <dict-tag :options="t_is_yes" :value="form.isPublish"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button @click="viewOpen = false">关闭</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="Tsp">
import {listTsp, getTsp, delTsp, addTsp, updateTsp} from "@/api/system/tsp";
import {ref} from "vue";
import {getAreaCode} from "@/api/system/sysCity";
import ParSelect from "@/components/ParSelect/index.vue";

const {proxy} = getCurrentInstance();
const {
  sys_user_sex,
  t_sp_service_time,
  t_is_yes,
  t_sp_status,
  t_sp_tag, t_sp_price_1, t_sp_price_2, t_sp_service_type
} = proxy.useDict('sys_user_sex', 't_sp_service_time', 't_is_yes', 't_sp_status', 't_sp_tag', 't_sp_price_1', 't_sp_price_2', 't_sp_service_type');

const spList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const mapComponentKey = ref(0);
const viewOpen = ref(false);
const refreshTime = ref(0);

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    spName: undefined,
    spAvatar: undefined,
    contactPhone: undefined,
    type: undefined,
    sex: undefined,
    workYears: undefined,
    serviceType: undefined,
    serviceTime: undefined,
    price: undefined,
    spDesc: undefined,
    showPic: undefined,
    certPic: undefined,
    platRec: undefined,
    isPublish: undefined,
    contSignTime: undefined,
    contStartTime: undefined,
    contEndTime: undefined,
    contLimit: undefined,
    cityCode: undefined,
    areaCode: undefined,
    addr: undefined,
    addrDesc: undefined,
    score: undefined,
    prodId: undefined,
    userId: undefined,
    status: undefined,
    statusReason: undefined,
    auditTime: undefined,
    auditor: undefined,
  },
  rules: {
    spAvatar: [
      {required: true, message: "头像不能为空", trigger: "blur"}
    ],
    serviceType: [
      {required: true, message: "教练类型不能为空", trigger: "blur"}
    ],
    spName: [
      {required: true, message: "姓名不能为空", trigger: "blur"}
    ],
    contactPhone: [
      {required: true, message: "手机号不能为空", trigger: "blur"}
      , {pattern: /^(1[3|4|5|6|7|8|9]\d{9})$|^(\d{3,4}-\d{7,8})$/, message: "请输入正确的手机号", trigger: "blur"}
    ],
    workYears: [
      {required: true, message: "从业年限不能为空", trigger: "blur"}
    ],
    birthDate: [
      {required: true, message: "出生日期不能为空", trigger: "blur"}
    ],
    tagList: [
      {required: true, message: "个人标签不能为空", trigger: "blur"}
    ],
    sex: [
      {required: true, message: "性别不能为空", trigger: "blur"}
    ],
    serviceTime: [
      {required: true, message: "服务时长不能为空", trigger: "blur"}
    ],
    price: [
      {required: true, message: "1v1价格不能为空", trigger: "blur"}
    ],
    price2: [
      {required: true, message: "1v2价格不能为空", trigger: "blur"}
    ],
    spDesc: [
      {required: true, message: "个人简介不能为空", trigger: "blur"}
    ],
    areaCode: [
      {required: true, message: "地区不能为空", trigger: "blur"}
    ],
    addr: [
      {required: true, message: "详细地址不能为空", trigger: "blur"}
    ],
    showPic: [
      {required: true, message: "个人风采不能为空", trigger: "blur"}
    ],
    certPic: [
      {required: true, message: "资质证明不能为空", trigger: "blur"}
    ],
    platRec: [
      {required: true, message: "平台推荐不能为空", trigger: "blur"}
    ],
    isPublish: [
      {required: true, message: "是否启用不能为空", trigger: "blur"}
    ],
  }
});

const {queryParams, form, rules} = toRefs(data);

/** 查询教练列表 */
function getList() {
  loading.value = true;
  listTsp(queryParams.value).then(response => {
    spList.value = response.rows;
    total.value = response.total;
    loading.value = false;
  });
}

// 取消按钮
function cancel() {
  open.value = false;
  reset();
}

// 表单重置
function reset() {
  form.value = {
    parId: undefined,
    spId: undefined,
    spName: undefined,
    spAvatar: undefined,
    contactPhone: undefined,
    type: 1,
    sex: undefined,
    birthDate: undefined,
    workYears: undefined,
    serviceType: undefined,
    serviceTime: undefined,
    price: undefined,
    price2: undefined,
    spDesc: undefined,
    showPic: undefined,
    certPic: undefined,
    platRec: undefined,
    isPublish: undefined,
    contSignTime: undefined,
    contStartTime: undefined,
    contEndTime: undefined,
    contLimit: undefined,
    cityCode: undefined,
    areaCode: undefined,
    areaPath: undefined,
    addr: undefined,
    addrDesc: undefined,
    longitude: 118.8083,
    latitude: 31.8639,
    score: undefined,
    prodId: undefined,
    userId: undefined,
    status: undefined,
    statusReason: undefined,
    auditTime: undefined,
    auditor: undefined,
    ext1: undefined,
    ext2: undefined,
    ext3: undefined,
    state: undefined,
    createTime: undefined,
    creator: undefined,
    modifyTime: undefined,
    modifier: undefined
  };
  mapComponentKey.value += 1;
  proxy.resetForm("spRef");
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.spId);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

/** 新增按钮操作 */
function handleAdd() {
  reset();
  refreshTime.value += 1
  open.value = true;
  title.value = "添加教练";
  mapComponentKey.value += 1;
}

function handleView(row) {
  const _spId = row.spId || ids.value
  getTsp(_spId).then(response => {
    form.value = response.data;
    form.value.showPicList = form.value.showPic.split(",");
    form.value.certPicList = form.value.certPic.split(",");
    viewOpen.value = true;
  });
}

/** 修改按钮操作 */
function handleUpdate(row) {
  reset();
  const _spId = row.spId || ids.value
  getTsp(_spId).then(response => {
    form.value = response.data;
    open.value = true;
    title.value = "修改教练";
    mapComponentKey.value += 1;
    refreshTime.value += 1
  });
}

/** 提交按钮 */
function submitForm() {
  proxy.$refs["spRef"].validate(valid => {
    if (valid) {
      if (form.value.spId != null) {
        form.value.statusReason = '';
        updateTsp(form.value).then(response => {
          proxy.$modal.msgSuccess("修改成功");
          open.value = false;
          getList();
        });
      } else {
        addTsp(form.value).then(response => {
          proxy.$modal.msgSuccess("新增成功");
          open.value = false;
          getList();
        });
      }
    }
  });
}

/** 删除按钮操作 */
function handleDelete(row) {
  const _spIds = row.spId || ids.value;
  proxy.$modal.confirm('是否确认删除教练编号为"' + _spIds + '"的数据项？').then(function () {
    return delTsp(_spIds);
  }).then(() => {
    getList();
    proxy.$modal.msgSuccess("删除成功");
  }).catch(() => {
  });
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download('system/tsp/export', {
    ...queryParams.value
  }, `sp_${new Date().getTime()}.xlsx`)
}

function handleCoordinateClicked(coordinate) {
  // 更新经纬度
  form.value.longitude = coordinate.lng;
  form.value.latitude = coordinate.lat;
  form.value.addr = coordinate.addr;
  getAreaCode({
    provinceExtName: coordinate.province,
    cityExtName: coordinate.city,
    districtExtName: coordinate.district,
    isOpenCity: 0
  }).then(response => {
    form.value.areaCode = response.data.district;
  });
}

function handleChange(value) {
  for (let dict of t_sp_price_1.value) {
    if (value == dict.value) {
      form.value.price2 = dict.ext1;
    }
  }
}

function handleServiceTypeChange(value) {
  form.value.price = undefined;
  form.value.price2 = undefined;
}

onActivated(() => {
  getList();
})

getList();
</script>
